import { computed } from "vue";
import { useStore } from "vuex";

/**
 * 映射store对应的属性（mapState｜mapGetters）
 * @param $store useStore()
 * @param mappers mapState([])｜mapGetters([])
 * @returns {[propName:string]: ComputedRefImpl,...}
 */
function getStoreMap(mappers) {
  const mapData = {};
  Object.keys(mappers).forEach((item) => {
    mapData[item] = computed(mappers[item].bind({ $store: useStore() }));
  });
  return mapData;
}
export { getStoreMap };
